﻿/************************************************************************************************
@atuhor:刘伟
@date: 2007-01-17
scriptfile:common files
function:用javaScript中显示相关html控件
************************************************************************************************/
  
/*****以下为用javaScript中显示相关html控件*****/
//var LoadImgUrl="/images/loading.gif";//加载图片路径

function ShowTextBox(name,value,size,className)
{
    return "<input type=\"text\" name=\""+name+"\" value=\""+value+"\" size=\""+size+"\"  class=\""+className+"\">";
}
function ShowReadOnlyTextBox(name,value,size,className)
{
    return "<input type=\"text\" id=\""+name+"\" name=\""+name+"\" value=\""+value+"\" size=\""+size+"\"  class=\""+className+"\" readonly=\"readonly\">";
}
function ShowReadOnlyTextBox(name,value,size,className,type)
{
    if(type=="1")
    {
        value = value.replace("T"," ");
        return "<input type=\"text\"  name=\""+name+"\" value=\""+value+"\" size=\""+size+"\"  class=\""+className+"\" readonly=\"readonly\">";
    }
    else if(type=="2")
    {
        value = value.substring(0,value.indexOf("T"));
        return "<input type=\"text\"  name=\""+name+"\" value=\""+value+"\" size=\""+size+"\"  class=\""+className+"\" readonly=\"readonly\">";
    }
    else
    {
        return "<input type=\"text\"  name=\""+name+"\" value=\""+value+"\" size=\""+size+"\"  class=\""+className+"\" readonly=\"readonly\">";
    }
}
//function ShowLoading(infoStr)
//{
//    return "<img src='"+SBasePath+LoadImgUrl+"' border='0' />"+infoStr;
//}

function ShowHidden(name,value)
{
    return "<input Type=\"hidden\" name=\""+name+"\" id=\""+name+"\" value=\""+value+"\">";
}
function ShowRadio(name,valuestr,checkedvalue,className)
{
    var rstr="";
    for(var i=0;i<valuestr.length;i++)
    {          
        if(checkedvalue==valuestr[i][0])
        {
           
             rstr+="<input type=\"radio\" name=\""+name+"\" checked=\"checked\"  class=\""+className+"\" value=\""+valuestr[i][0]+"\">"+valuestr[i][1]; 
        }
        else
        {   
            rstr+="<input type=\"radio\" name=\""+name+"\" class=\""+className+"\" value=\""+valuestr[i][0]+"\">"+valuestr[i][1];
        }
    }   
    return rstr;
}

function ShowCheckBox(name,valuestr,checkedvalue,className,onchanfunc)
{
    var rstr="";
    for(var i=0;i<valuestr.length;i++)
    {          
        if(checkedvalue==valuestr[i][0])
        {
           
             rstr+="<input type=\"checkbox\" id=\""+name+"\" name=\""+name+"\" checked=\"checked\" onclick=\""+onchanfunc+"\"  class=\""+className+"\" value=\""+valuestr[i][0]+"\">"+valuestr[i][1]; 
        }
        else
        {   
            rstr+="<input type=\"checkbox\" id=\""+name+"\" name=\""+name+"\"  onclick=\""+onchanfunc+"\"  class=\""+className+"\" value=\""+valuestr[i][0]+"\">"+valuestr[i][1];
        }
    }   
    return rstr;
}

function ShowCheckBoxNew(name,valuestr,checkedvalue,className)
{
    var rstr="";
    for(var i=0;i<valuestr.length;i++)
    {          
        var flag=false;
        for(var j=0;j<checkedvalue.length;j++)
        {
            if(checkedvalue[j]==valuestr[i][0])
            {
                flag=true;
                break;
            }
        
        }
        if(flag==true)
        {
           
             rstr+="<input type=\"checkbox\" id=\""+name+"\" name=\""+name+"\" checked=\"checked\"  class=\""+className+"\" value=\""+valuestr[i][0]+"\">"+valuestr[i][1]; 
        }
        else
        {   
            rstr+="<input type=\"checkbox\" id=\""+name+"\" name=\""+name+"\"  class=\""+className+"\" value=\""+valuestr[i][0]+"\">"+valuestr[i][1];
        }
    }   
    return rstr;
}
var ShowCheckBoxNew=function(name,valuestr,checkedvalue,disabled,onchanfunc)
{
    var rstr="";
    for(var i=0;i<valuestr.length;i++)
    {          
        var flag=false;
        for(var j=0;j<checkedvalue.length;j++)
        {
            if(checkedvalue==valuestr[i][0])
            {
                flag=true;
                break;
            }
        
        }
        if(flag==true)
        {
           
             rstr+="<input type=\"checkbox\" id=\""+name+"\" name=\""+name+"\" checked=\"checked\"  "+disabled+" value=\""+valuestr[i][0]+"\" onclick=\""+onchanfunc+"\" />"+valuestr[i][1]; 
        }
        else
        {   
            rstr+="<input type=\"checkbox\" id=\""+name+"\" name=\""+name+"\"  "+disabled+" value=\""+valuestr[i][0]+"\" onclick=\""+onchanfunc+"\" />"+valuestr[i][1];
        }
    }   
    return rstr;
}

function ShowImage(name,src,alt,className)
{
   return "<img name=\""+name+"\" id=\""+name+"\" type=\"image\" src=\""+src+"\" alt=\""+alt+"\" class=\""+className+"\" />";
}

//name=值控件名称,func=调用的上传函数名称,value=原来的值
//显示上传图片文件控件
function ShowCreatorImgFile(id,name,value,func)
{
    var ret= '<input type="hidden" name="'+name+'" id="'+id+'" value="'+value+'" /><input type="button"\
                                    value="上传" onclick="'+func+'(\''+id+'\')" /><div id="'+id+'ShowDiv">';
    if(value!=""&& value!=null)
    {
        ret+='<img src="'+value+'" width="120",height="90" border="0" >';
    }
    else
    {
         ret+='<img src="'+SBasePath+Empty_Img+'" width="120",height="90" border="0" >';
    }
      ret+='</div>';
      return ret;
}
function ShowCreatorUserImgFile(id,name,value,func)
{
    var ret= '<input type="hidden" name="'+name+'" id="'+id+'" value="'+value+'" /><input type="button"\
                                    value="上传" onclick="'+func+'(\''+id+'\')" /><div id="'+id+'ShowDiv">';
    if(value!=""&& value!=null)
    {
        ret+='<img src="'+value+'" width="90",height="120" border="0" >';
    }
    else
    {
         ret+='<img src="'+SBasePath+Empty_Img+'" width="90",height="120" border="0" >';
    }
      ret+='</div>';
      return ret;
}
//name=值控件名称,func=调用的上传函数名称,value=原来的值
//显示上传文件控件
function ShowCreatorFile(id,name,value,func)
{
    var ret= '<input type="hidden" name="'+name+'" id="'+id+'" value="'+value+'" /><input type="button"\
                                    value="上传" onclick="'+func+'(\''+id+'\')" /><div id="'+id+'ShowDiv">';
    if(value!=""&& value!=null)
    {
        ret+='文件名为:'+value;
    }
    else
    {
         ret+='文件名为:';
    }
      ret+='</div>';
      return ret;
}
                                    
function ShowPasswordBox(name,value,size,className)
{
    return "<input type=\"password\" name=\""+name+"\" id=\""+name+"\" value=\""+value+"\" size=\""+size+"\"  class=\""+className+"\">";
}

function ShowButton(name,value,clickfunction,className)
{
    return "<input type=\"button\" name=\""+name+"\" id=\""+name+"\" onclick=\""+clickfunction+"\"  class=\""+className+"\" value=\""+value+"\">";
}

function ShowTextArea(name,value,cols,rows,className)
{
    return "<TEXTAREA  name=\""+name+"\" id=\""+name+"\" cols=\""+cols+"\" rows=\""+rows+"\" class=\""+className+"\">"+value+"</TextArea>";
}

function ShowReadOnlyTextArea(name,value,cols,rows,className)
{
    return "<TEXTAREA  name=\""+name+"\" id=\""+name+"\" cols=\""+cols+"\" rows=\""+rows+"\" class=\""+className+"\" readonly=\"readonly\" >"+value+"</TextArea>";
}


function ShowSelect(name,valuestr,selectedValue,className)
{

    var rstr="<select id=\""+name+"\" name=\""+name+"\" class=\""+className+"\">";
   
   for(var i=0;i<valuestr.length;i++)
   {          
        if(selectedValue==valuestr[i][0])
        {
           
             rstr+="<option value='"+valuestr[i][0]+"' selected>"+valuestr[i][1]+"</option>";
        }
        else
        {   
            rstr+="<option value='"+valuestr[i][0]+"'>"+valuestr[i][1]+"</option>";
        }
   
   }
   rstr+=" </select>";
  
   return rstr;
}
//特别的绑定的是值是名字
function ShowSelectT(name,valuestr,selectedValue,className)
{
    
    var rstr="<select id=\""+name+"\" name=\""+name+"\" class=\""+className+"\">";
   
   for(var i=0;i<valuestr.length;i++)
   {         
        if(selectedValue==valuestr[i][1])
        {
           
             rstr+="<option value='"+valuestr[i][1]+"' selected>"+valuestr[i][1]+"</option>";
        }
        else
        {   
            rstr+="<option value='"+valuestr[i][1]+"'>"+valuestr[i][1]+"</option>";
        }
   
   }
   rstr+=" </select>";
  
   return rstr;
}
function ShowSelect(name,valuestr,selectedValue,className,blank,btitle,onchange)
{
    var rstr="";
   if(onchange!=null && onchange!="")
   {
        rstr+="<select id=\""+name+"\" name=\""+name+"\" class=\""+className+"\" onchange=\""+onchange+"\">";
   }
   else
   {
        rstr+="<select id=\""+name+"\" name=\""+name+"\" class=\""+className+"\">";
   }
   if(blank!=null && blank==true)
   {
        if(btitle!=null && btitle!="")
        {
            rstr+="<option value=''>"+btitle+"</option>";
        }
        else
        {
            rstr+="<option value=''>-全部-</option>";
        }
   };
   for(var i=0;i<valuestr.length;i++)
   {          
        if(selectedValue==valuestr[i][0])
        {
           
             rstr+="<option value='"+valuestr[i][0]+"' selected>"+valuestr[i][1]+"</option>";
        }
        else
        {   
            rstr+="<option value='"+valuestr[i][0]+"'>"+valuestr[i][1]+"</option>";
        }
   
   }
   rstr+=" </select>";
  
   return rstr;
}
//显示日期选择图片按钮
var ShowCalenderImg=function(name)
{
    var _id=(new Date()).getTime();
    return '<img alt="" src="'+SBasePath+'/images/diary[1].gif" id="Img'+_id+'" style="cursor: pointer;" title="选择日期" onclick="displayCalendar('+name+',\'yyyy-mm-dd\',this)" /> ';
   
};
//酒店显示日期选择图片按钮
var ShowCalenderImgHotel=function(name)
{
    var _id=(new Date()).getTime();
    return '<img alt="" src="'+SBasePath+'/images/hoteldata.gif" id="Img'+_id+'" style="cursor: pointer;" title="选择日期" onclick="displayCalendar('+name+',\'yyyy-mm-dd\',this)" /> ';
   
};
